home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / x11-common < prev    next >
Text File  |  2008-10-23  |  2KB  |  91 lines

  1. #!/bin/sh
  2. # /etc/init.d/x11-common: set up the X server and ICE socket directories
  3. ### BEGIN INIT INFO
  4. # Provides:          x11-common
  5. # Required-Start:    $local_fs
  6. # Required-Stop:     $local_fs
  7. # Default-Start:     S
  8. # Default-Stop:
  9. ### END INIT INFO
  10.  
  11. set -e
  12.  
  13. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  14. SOCKET_DIR=/tmp/.X11-unix
  15. ICE_DIR=/tmp/.ICE-unix
  16.  
  17. . /lib/lsb/init-functions
  18. if [ -f /etc/default/rcS ]; then
  19.   . /etc/default/rcS
  20. fi
  21.  
  22. do_restorecon () {
  23.   # Restore file security context (SELinux).
  24.   if which restorecon >/dev/null 2>&1; then
  25.     restorecon "$1"
  26.   fi
  27. }
  28.  
  29. set_up_socket_dir () {
  30.   if [ "$VERBOSE" != no ]; then
  31.     log_begin_msg "Setting up X server socket directory $SOCKET_DIR..."
  32.   fi
  33.   if [ -e $SOCKET_DIR ] && [ ! -d $SOCKET_DIR ]; then
  34.     mv $SOCKET_DIR $SOCKET_DIR.$$
  35.   fi
  36.   mkdir -p $SOCKET_DIR
  37.   chown root:root $SOCKET_DIR
  38.   chmod 1777 $SOCKET_DIR
  39.   do_restorecon $SOCKET_DIR
  40.   [ "$VERBOSE" != no ] && log_end_msg 0 || return 0
  41. }
  42.  
  43. set_up_ice_dir () {
  44.   if [ "$VERBOSE" != no ]; then
  45.     log_begin_msg "Setting up ICE socket directory $ICE_DIR..."
  46.   fi
  47.   if [ -e $ICE_DIR ] && [ ! -d $ICE_DIR ]; then
  48.     mv $ICE_DIR $ICE_DIR.$$
  49.   fi
  50.   mkdir -p $ICE_DIR
  51.   chown root:root $ICE_DIR
  52.   chmod 1777 $ICE_DIR
  53.   do_restorecon $ICE_DIR
  54.   [ "$VERBOSE" != no ] && log_end_msg 0 || return 0
  55. }
  56.  
  57. do_status () {
  58.     if [ -d $ICE_DIR ] && [ -d $SOCKET_DIR ]; then
  59.       return 0
  60.     else
  61.       return 4
  62.     fi
  63. }
  64.  
  65. case "$1" in
  66.   start)
  67.     set_up_socket_dir
  68.     set_up_ice_dir
  69.   ;;
  70.  
  71.   restart|reload|force-reload)
  72.     /etc/init.d/x11-common start
  73.   ;;
  74.  
  75.   stop)
  76.    :
  77.   ;;
  78.  
  79.   status)
  80.     do_status
  81.   ;;
  82.   *)
  83.     log_success_msg "Usage: /etc/init.d/x11-common {start|stop|status|restart|reload|force-reload}"
  84.     exit 1
  85.     ;;
  86. esac
  87.  
  88. exit 0
  89.  
  90. # vim:set ai et sts=2 sw=2 tw=0:
  91.